package com.example.demo.utils;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class CookieUtil {
    public static final String HTTPS = "https";
    public static void addCookie(String name , String value, String path, HttpServletRequest request, HttpServletResponse response)
    {
        Cookie cookie = new Cookie(name,value);
        if(path!=null){
            cookie.setPath(path);
        }
        cookie.setMaxAge(60 * 60 * 24 * 5);
        response.addCookie(cookie);
        response.setHeader("Set-Cookie", "HttpOnly;Secure;SameSite=None");
    }
}
